home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-03-11 | 3.4 KB | 83 lines | [TEXT/MSWD] |
- \ *************** Some Brodie extensions ****************
-
- 0 28 +md ! decimal page \ keep screen clear, echo off
- : SPACES ( n -- )
- ?dup IF 0 DO space LOOP THEN ; \ emit n spaces
- : D- dnegate d+ ; \ double length number subtraction
- : .( 41 word here count type ; \ interactive printing utility
- : <> ( n1 n2 -- flag ) = 0= ; \ true if n1 and n2 are not the same
- : 2- ( n -- n-2 ) ,$ 5556 ; MACRO \ subq #2,(ps)
- : R@ ( -- n ) ( rstack: n -- n ) \ same as r
- ,$ 3d17 ; MACRO \ move (a7),-(a6)
- : I ( -- n ) ( rstack: n -- n ) ( same as r and r@ )
- ,$ 3d17 ; MACRO \ move (a7),-(a6)
- : J ( -- n ) ( rstack: n x m -- n x m )
- ,$ 3d2f ,$ 0004 ; MACRO \ move 4(a7),-(a6)
- : ? ( addr -- ) @ . ; ( print variable )
- : ERASE ( addr n -- ) 0 fill ; \ Fill addr with n zeros.
- : KEY? ( -- flag ) ?terminal ;
- : MOVE ( addr1 addr2 count -- ) cmove ;
- : CMOVE> ( addr1 addr2 count -- ) cmove ;
- : STRING ( c -- ) \ compile a string
- word here c@ 1+ ,$ 5256 ,$ 256 ,$ fffe allot ; \ keep HERE even
- \ These three words are redefined:
- : (word) word ;
- : WORD ( c -- addr ) (word) here ;
- : (number) number ;
- : NUMBER ( addr -- d ) (number) IF s>d ELSE 0 0 THEN ;
- : COMPILE ( -- ) \ compile the next word from within a colon def.
- token latest search IF \ ( -- n ) addr of token
- ,$ 24FC ,$ 24FC ,$ 4EAB , \ move.l #[move.l jsr n(a3)],(a2)+
- ELSE here count type space ." not found." abort
- THEN ; IMMEDIATE
-
- \ ******************** Extra extensions *************************
- : DABS dup 0< if -1 * then ;
-
- \ String storage
- : ?DEFINING ( -- flag ) cstate c@ ; \ true if defining
- : ASCII ( -- c ) 32 word here 1+ c@ \ c = ascii of next character
- ?defining IF literal THEN ; IMMEDIATE
- : EVEN ( n -- n' ) dup 2 mod + ; \ round up to even number
- : ," ( -- ) ascii " word \ get a quoted string
- here c@ 1+ even allot ; IMMEDIATE
-
- \ Font setting
- : !FONT ( n -- ) >r ,$ A887 ( _TextFont ) ; macro \ set font
- : !FSIZE ( n -- ) >r ,$ A88A ( _TextSize ) ; macro \ set size
- : !FACE ( face -- ) >r ,$ A888 ( _TextFace ) ; macro \ set style
- : !FMODE ( mode -- ) >r ,$ A889 ( _TextMode ) ; macro \ set mode
- : SYSFONT ( -- ) 0 !font 12 !fsize ; \ set System font
- : MONACO9 ( -- ) 4 !font 09 !fsize 0 !fmode ; \ set Normal font
-
- \ Window
- : RCLIP ( rect -- ) a>r ,$ A87B ( _ClipRect ) ;
- : WINDOW ( -- d ) 0 +md 2@ ; \ d = window pointer
- : WSIZE ( h v -- ) \ change the window size call: x y WSIZE
- 2dup 8 +md 2! \ set the scroll rect
- window 2>r 2>r 256 >r ,$ A91D ( _SizeWindow )
- 4 +md rclip ; \ set drawing rect to whole window
- : WTITLE ( string.addr -- ) \ set the window title
- window 2>r a>r ,$ A91A ( _SetWTitle ) ;
-
- \ Colors (back and foreground)
- 33 constant BLACK 30 constant WHITE
- 205 constant RED 341 constant GREEN
- 409 constant BLUE 273 constant CYAN
- 137 constant MAGENTA 69 constant YELLOW
- : FCOLOR ( color.code -- ) 0 2>r ,$ A862 ; ( _ForeColor )
- : BCOLOR ( back.color -- ) 0 2>r ,$ A863 ; ( _BackColor )
-
- \ Random numbers
- : SEED ( -- daddr ) ,$ 2d15 126 0 dnegate d+ ;
- : TIME ( -- d ) 524 0 dl@ ;
- : RANDOMIZE time seed dl! ;
- : RANDOM ( n -- n' )
- 0 >r ,$ A861 r> ( _Random )
- swap 32768 */ abs ; ( scale to size from stack )
-
- \ ******************************************************************
- : READY -1 28 +md ! \ Use READY to set echo on again!
- PAGE ." Extensions loaded..." CR ;
-
-